**Clean wave 2**

**import raw data
import spss using "INDU0006_OUTPUT_wid.sav", clear

***NOTE: variables are labeled with "2" to define them as taking place in wave 2 of the survey


**Rename and define education variable
rename educ educ2
label define educ_label 1 "No HS" 2 "High school graduate" 3 "Some college" 4 "2-year" 5 "4-year" 6 "Post-grad"
label values educ2 educ_label

**Designate weight for wave 2
rename weight weight2

**Define and label household size
rename q1 hhsize2
label define hhsizelabel 1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6" 7 "7" 8 "8" 9 "9" 10 "10" 11 "11" 12 "12" 13 "13" 14 "14" 15 "15" 16 "16" 17 "17" 18 "18" 19 "19" 20 "20"
label values hhsize2 hhsizelabel

**Define and label number of children under 5 in the household
rename q2_a hh_under52
recode hh_under52 (1=0) (2=1) (3=2) (4=3) (5=4)
label define hhunder5label 0 "0" 1 "1" 2 "2" 3 "3" 4 "More than 3"
label values hh_under52 hhunder5label

**Define and label number of people over 65 in the household
gen hh_over652=.
replace hh_over652=0 if q2_b==1
replace hh_over652=1 if q2_b==2
replace hh_over652=2 if q2_b==3
replace hh_over652=3 if q2_b==4
replace hh_over652=4 if q2_b==5
label define hh_over65_label 0 "0" 1 "1" 2 "2" 3 "3" 4 "more than 3"
label val hh_over652 hh_over65_label
drop q2_b

**Define and label number of people with disability in the household
gen hh_disability2=.
replace hh_disability2=0 if q2_c==1
replace hh_disability2=1 if q2_c==2
replace hh_disability2=2 if q2_c==3
replace hh_disability2=3 if q2_c==4
replace hh_disability2=4 if q2_c==5
label define hh_disability_label 0 "0" 1 "1" 2 "2" 3 "3" 4 "more than 3"
label val hh_disability2 hh_disability_label
drop q2_c

**Did respondent move between wave 1 and wave 2, and if so what is their new dwelling type?
rename q4 moved
rename q6 dwelling_moved2

gen dwelling_type2=.
replace dwelling_type2=1 if dwelling_moved2 ==1
replace dwelling_type2=2 if dwelling_moved2 ==2
replace dwelling_type2=3 if dwelling_moved2 ==4
replace dwelling_type2=4 if dwelling_moved2 ==5
replace dwelling_type2=5 if dwelling_moved2 ==9
label var dwelling_type2 "Dwelling Type"
label define dwelling_typelabel 1 "Trailer or mobile home" 2 "Apartment/duplex/condominum" 3 "Detached, single family home" 4 "Attached single family home" 5 "Other"
label values dwelling_type2 dwelling_typelabel

rename q6_open dwelling_open2


**Rename income brackets for individuals based on their household size
rename q69_1 hh1_income2
rename q69_2 hh2_income2
rename q69_3 hh3_income2
rename q69_4 hh4_income2
rename q69_5 hh5_income2
rename q69_6 hh6_income2
rename q69_7 hh7_income2
rename q69_8 hh8_income2
rename q69_all income2


**Renaming responses to dwelling conditions (e.g., household deficiencies), then cleaning responses
rename q7_1 poor_insulation2
rename q7_2 drafty2
rename q7_3 mold2
rename q7_4 holes2
rename q7_5 plumbing2
rename q7_6 exposed_sockets2
rename q7_7 nonworking_stove_fridge2
rename q7_8 broken_heating2
rename q7_9 broken_ac2

replace poor_insulation2=0 if poor_insulation2 !=1
label define poorinsulation_label 0 "no" 1 "yes"
label values poor_insulation2 poorinsulation_label

replace drafty2=0 if drafty2 !=1
label define drafty_label 0 "no" 1 "yes"
label values drafty2 drafty_label

replace mold2=0 if mold2 !=1
label define mold_label 0 "no" 1 "yes"
label values mold2 mold_label

replace holes2=0 if holes2 !=1
label define holes_label 0 "no" 1 "yes"
label values holes2 holes_label

replace plumbing2=0 if plumbing2 !=1
label define plumbing_label 0 "no" 1 "yes"
label values plumbing2 plumbing_label

replace exposed_sockets2=0 if exposed_sockets2 !=1
label define exposed_sockets_label 0 "no" 1 "yes"
label values exposed_sockets2 exposed_sockets_label

replace nonworking_stove_fridge2=0 if nonworking_stove_fridge2 !=1
label define nonworking_stove_label 0 "no" 1 "yes"
label values nonworking_stove_fridge2 nonworking_stove_label

replace broken_heating2=0 if broken_heating2 !=1
label define broken_heating_label 0 "no" 1 "yes"
label values broken_heating2 broken_heating_label

replace broken_ac2=0 if broken_ac2 !=1
label define broken_ac_label 0 "no" 1 "yes"
label values broken_ac2 broken_ac_label

***Binary variable representing if a respondent indicated they had poor insulation, drafty air in their home, mold, holes, bad plumbing, exposed sockets, a stove or fridge that isn't currently working, or broken AC or heating
gen dwelling_condition2=.

replace dwelling_condition2=0 if poor_insulation2==0 & drafty2==0 & mold2 ==0 & holes2==0 & plumbing2==0 & exposed_sockets2==0 & nonworking_stove_fridge2==0 & broken_heating2==0 & broken_ac2==0

replace dwelling_condition2=1 if poor_insulation2==1 | drafty2==1 | mold2==1 | holes2==1 | plumbing2==1 | exposed_sockets2==1 |nonworking_stove_fridge2==1 | broken_heating2==1 | broken_ac2==1

label define dwelling_conditionlabel 0 "No dwelling conditions" 1 "At least 1 dwelling condition"
label values dwelling_condition2 dwelling_conditionlabel


**Fuel type that household uses for energy (electricity, gas, wood, propane, or fuel oil)
rename q8_1 electricity2
rename q8_2 gas2
rename q8_3 wood2
rename q8_4 propane2
rename q8_5 fueloil2

replace electricity2=0 if electricity2 !=1
label define electricity_label 0 "no" 1 "yes"
label values electricity2 electricity_label

replace gas2=0 if gas2 !=1
label define gas_label 0 "no" 1 "yes"
label values gas2 gas_label

replace wood2=0 if wood2 !=1
label define wood_label 0 "no" 1 "yes"
label values wood2 wood_label

replace propane2=0 if propane2 !=1
label define propane_label 0 "no" 1 "yes"
label values propane2 propane_label

replace fueloil2=0 if fueloil2 !=1
label define fueloil_label 0 "no" 1 "yes"
label values fueloil2 fueloil_label

** Who pays for household fuel? Options: household pays all, all included in rent, some are paid by the household, some included in rent
gen fuel_payment2=.
replace fuel_payment2=1 if q11_1==1 
replace fuel_payment2=2 if q11_1==2
replace fuel_payment2=3 if q11_1==3
replace fuel_payment2=4 if q11_1==4
replace fuel_payment2=5 if q11_1>4
label var fuel_payment2 "Fuel Payment"
label define fuel_paymentlabel 0 "None" 1 "Household pays all" 2 "All included in Rent" 3 "Some household, some rent" 4 "Other" 5 "Dont know/not asked"
label values fuel_payment2 fuel_paymentlabel


**respondents rating of trust in their electricity provider
rename q10 trust_energyco2
label define trust_label 0 "0 - Don't trust electricity company at all" 1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6" 7 "7" 8 "8" 9 "9" 10 "10 - Fully trust electricity company"
label values trust_energyco2 trust_label



**are respondents' recent energy bills less than, more than, are about the same amount as a typical month
rename q12 energybill_change2

**Does a household member require the use of an at-home electronic device?
rename q13 electronic_device2
recode electronic_device2 (2=0)
label define device_label 0 "no" 1 "yes"
label values electronic_device2 device_label

**Has household installed energy efficient appliances to keep their energy prices lower?
rename q14_1 efficient_appliances2
recode efficient_appliances2 (2=0)
label define appliance_label 0 "no" 1 "yes"
label values efficient_appliances2 appliance_label
rename q14_2 efficient_insulation2
recode efficient_insulation2 (2=0)
label define insulation_label 0 "no" 1 "yes"
label values efficient_insulation2 insulation_label
rename q14_3 efficient_ac2
recode efficient_ac2 (2=0)
label define ac_label 0 "no" 1 "yes"
label values efficient_ac2 ac_label
rename q14_4 efficient_smartmeter2
recode efficient_smartmeter2 (2=0)
label define smartmeter_label 0 "no" 1 "yes"
label values efficient_smartmeter2 smartmeter_label
rename q14_5 efficient_lights2
recode efficient_lights2 (2=0)
label define lights_label 0 "no" 1 "yes"
label values efficient_lights2 lights_label
rename q14_6 efficient_hometemp2
recode efficient_hometemp2 (2=0)
label define hometemp_label 0 "no" 1 "yes"
label values efficient_hometemp2 hometemp_label
rename q14_7 efficient_devices2
recode efficient_devices2 (2=0)
label define devices_label 0 "no" 1 "yes"
label values efficient_devices2 devices_label
rename q14_8 efficient_hungwindow2
recode efficient_hungwindow2 (2=0)
label define hungwindow_label 0 "no" 1 "yes"
label values efficient_hungwindow2 hungwindow_label


***Could not pay household energy bill in the last 3 months
rename q15 hhbill_3months2
recode hhbill_3months2 (2=0)
label define hhbill_3mo_label 0 "no" 1 "yes"
label values hhbill_3months2 hhbill_3mo_label

gen hhbill_june=0
replace hhbill_june=1 if q16_1==1

gen hhbill_july=0
replace hhbill_july=1 if q16_2==1

gen hhbill_august=0
replace hhbill_august=1 if q16_3==1

drop q16_1 q16_2 q16_3


**did household receive a disconnection notice in last 3 months
rename q17 notice_3months2
recode notice_3months2 (2=0)
label define notice_3mo_label 0 "no" 1 "yes"
label values notice_3months2 notice_3mo_label


gen notice_june=0
replace notice_june=1 if q18_1==1

gen notice_july=0
replace notice_july=1 if q18_2==1

gen notice_august=0
replace notice_august=1 if q18_3==1

drop q18_1 q18_2 q18_3

**did household get disconnected in last 3 months
gen disconnect_3months2=0
replace disconnect_3months2=1 if q19==1
recode disconnect_3months2 (2=0)
label define disconnect_3mo_label 0 "no" 1 "yes"
label values disconnect_3months2 disconnect_3mo_label


gen disconnect_june=0
replace disconnect_june=1 if q20_1==1

gen disconnect_july=0
replace disconnect_july=1 if q20_2==1

gen disconnect_august=0
replace disconnect_august=1 if q20_3==1

drop q20_1 q20_2 q20_3


**if a respondent recieved a disconnection notice, in which form did that notice arrive (a call, a letter, a door knock, an email, or a text?)
rename q21_1 form_call2
recode form_call2 (2=0)
label define form_call2_label 0 "no" 1 "yes"
label values form_call2 form_call2_label
rename q21_2 form_letter2
recode form_letter2 (2=0)
label define form_letter2_label 0 "no" 1 "yes"
label values form_letter2 form_letter2_label
rename q21_3 form_doorknock2
recode form_doorknock2 (2=0)
label define form_doorknock2_label 0 "no" 1 "yes"
label values form_doorknock2 form_doorknock2_label
rename q21_4 form_email2
recode form_email2 (2=0)
label define form_email2_label 0 "no" 1 "yes"
label values form_email2 form_email2_label
rename q21_5 form_text2
recode form_text2 (2=0)
label define form_text2_label 0 "no" 1 "yes"
label values form_text2 form_text2_label


**if a respondent recieved a disconnection notice, how did they respond (contacted utility, set up a payment plan, sought legal service, sought government assistance, searched online for solutions, made changes to reduce energy consumption, or moved?)
rename q22_1 response_contactutility2
recode response_contactutility2 (2=0)
label define response_contact_label 0 "no" 1 "yes"
label values response_contactutility2 response_contact_label
rename q22_2 response_paymentplan2
recode response_paymentplan2 (2=0)
label define response_paymentplan_label 0 "no" 1 "yes"
label values response_paymentplan2 response_paymentplan_label
rename q22_3 response_legalservices2
recode response_legalservices2 (2=0)
label define response_legalservices_label 0 "no" 1 "yes"
label values response_legalservices2 response_legalservices_label
rename q22_4 response_assistance2
recode response_assistance2 (2=0)
label define response_assistance_label 0 "no" 1 "yes"
label values response_assistance2 response_assistance_label
rename q22_5 response_internet2
recode response_internet2 (2=0)
label define response_internet_label 0 "no" 1 "yes"
label values response_internet2 response_internet_label
rename q22_6 response_homechanges2
recode response_homechanges2 (2=0)
label define response_homechanges_label 0 "no" 1 "yes"
label values response_homechanges2 response_homechanges_label
rename q22_7 response_reduceenergy2
recode response_reduceenergy2 (2=0)
label define response_reduceenergy_label 0 "no" 1 "yes"
label values response_reduceenergy2 response_reduceenergy_label
rename q22_8 response_moved2
recode response_moved2 (2=0)
label define response_moved_label 0 "no" 1 "yes"
label values response_moved2 response_moved_label


**if a respondent received a disconnection notice, did they seek help from the following sources (a government agency, a bank, a payday loan service, their utility, a non profit, a faith based organization, or friends/family members?)
rename q23_1 sought_govagency2
recode sought_govagency2 (2=0)
label define sought_agency2_label 0 "no" 1 "yes"
label values sought_govagency2 sought_agency2_label
rename q23_2 sought_bank2
recode sought_bank2 (2=0)
label define sought_bank2_label 0 "no" 1 "yes"
label values sought_bank2 sought_bank2_label
rename q23_3 sought_payday2
recode sought_payday2 (2=0)
label define sought_payday2_label 0 "no" 1 "yes"
label values sought_payday2 sought_payday2_label
rename q23_4 sought_utility2
recode sought_utility2 (2=0)
label define sought_utility2_label 0 "no" 1 "yes"
label values sought_utility2 sought_utility2_label
rename q23_5 sought_nonprofit2
recode sought_nonprofit2 (2=0)
label define sought_nonprofit2_label 0 "no" 1 "yes"
label values sought_nonprofit2 sought_nonprofit2_label
rename q23_6 sought_faithbased2
recode sought_faithbased2 (2=0)
label define sought_faithbased2_label 0 "no" 1 "yes"
label values sought_faithbased2 sought_faithbased2_label
rename q23_7 sought_family_friends2
recode sought_family_friends2 (2=0)
label define sought_family_friends2_label 0 "no" 1 "yes"
label values sought_family_friends2 sought_family_friends2_label


**did the respondent receive the help they sought
rename q24_a received_govagency2
recode received_govagency2 (2=0)
label define received_agency_label 0 "no" 1 "yes"
label values received_govagency2 received_agency_label
rename q24_b received_bank2
recode received_bank2 (2=0)
label define received_bank_label 0 "no" 1 "yes"
label values received_bank2 received_bank_label
rename q24_c received_payday2
recode received_payday2 (2=0)
label define received_payday_label 0 "no" 1 "yes"
label values received_payday2 received_payday_label
rename q24_d received_utility2
recode received_utility2 (2=0)
label define received_utility_label 0 "no" 1 "yes"
label values received_utility2 received_utility_label
rename q24_e received_nonprofit2
recode received_nonprofit2 (2=0)
label define received_nonprofit_label 0 "no" 1 "yes"
label values received_nonprofit2 received_nonprofit_label
rename q24_f received_faithbased2
recode received_faithbased2 (2=0)
label define received_faithbased_label 0 "no" 1 "yes"
label values received_faithbased2 received_faithbased_label
rename q24_g received_family_friends2
recode received_family_friends2 (2=0)
label define received_family_friends_label 0 "no" 1 "yes"
label values received_family_friends2 received_family_friends_label




** the following responses indicate how the respondent answered that they would respond to a notice of disconnection in a hypothetical scenario
rename q25_1 hypothetical_contactutility
rename q25_2 hypothetical_paymentplan
rename q25_3 hypothetical_legalservices
rename q25_4 hypothetical_assistance
rename q25_5 hypothetical_internet
rename q25_6 hypothetical_homechanges
rename q25_7 hypothetical_reduceenergy
rename q25_8 hypothetical_moved

rename q26_1 hypothetical_govagency
rename q26_2 hypothetical_bank
rename q26_3 hypothetical_payday
rename q26_4 hypothetical_utility
rename q26_5 hypothetical_nonprofit
rename q26_6 hypothetical_faithbasd
rename q26_7 hypothetical_family_friends

*rename q27_b_1
***

**when a respondent was disconnected, how did they respond (moved temporarily/permanently, lived without electricity, got helped from someone other than the utility company, paid off their bill, used an alternative energy source, used their car or a batter for energy?)
rename q27_b_1 response_moved_temp2
recode response_moved_temp2 (2=0)
label define response_moved_temp_label 0 "no" 1 "yes"
label values response_moved_temp2 response_moved_temp_label
rename q27_b_2 response_moved_perm2
recode response_moved_perm2 (2=0)
label define response_moved_perm_label 0 "no" 1 "yes"
label values response_moved_perm2 response_moved_perm_label
rename q27_b_3 response_livedwithout2
recode response_livedwithout2 (2=0)
label define response_livedwithout_label 0 "no" 1 "yes"
label values response_livedwithout2 response_livedwithout_label
rename q27_b_4 response_otherhelp2
recode response_otherhelp2 (2=0)
label define response_otherhelp_label 0 "no" 1 "yes"
label values response_otherhelp2 response_otherhelp_label
rename q27_b_5 response_paidoff2
recode response_paidoff2 (2=0)
label define response_paidoff_label 0 "no" 1 "yes"
label values response_paidoff2 response_paidoff_label
rename q27_b_6 response_usedothers2
recode response_usedothers2 (2=0)
label define response_usedothers_label 0 "no" 1 "yes"
label values response_usedothers2 response_usedothers_label
rename q27_b_7 response_carorbattery2
recode response_carorbattery2 (2=0)
label define response_carorbattery_label 0 "no" 1 "yes"
label values response_carorbattery2 response_carorbattery_label


**For respondents who were disconnected, how much was the reconnection fee to get service turned back on
rename q28 reconnection_cost2


**did a respondent receieve assistance in paying their energy bill in the last 3 months from the following sources: government agency, their energy provider, a friend or family member, a faith-based organization, a nonprofit, a payday lender, or a bank loan
rename q30_1 gov_agency_3mos2
rename q30_2 energy_provider_3mos2
rename q30_3 friend_family_3mos2
rename q30_4 faith_org_3mos2
rename q30_5 nonprofit_3mos2
rename q30_6 payday_lender_3mos2
rename q30_7 bankloan_3mos2


replace gov_agency_3mos2=0 if gov_agency_3mos2 !=1
label define gov_agency_3label 0 "no" 1 "yes"
label values gov_agency_3mos2 gov_agency_3label

replace energy_provider_3mos2=0 if energy_provider_3mos2 !=1
label define energy_provider_3label 0 "no" 1 "yes"
label values energy_provider_3mos2 energy_provider_3label

replace friend_family_3mos2=0 if friend_family_3mos2 !=1
label define friend_family_3label 0 "no" 1 "yes"
label values friend_family_3mos2 friend_family_3label

replace faith_org_3mos2=0 if faith_org_3mos2 !=1
label define faith_org_3label 0 "no" 1 "yes"
label values faith_org_3mos2 faith_org_3label

replace nonprofit_3mos2=0 if nonprofit_3mos2 !=1
label define nonprofit_3label 0 "no" 1 "yes"
label values nonprofit_3mos2 nonprofit_3label

replace payday_lender_3mos2=0 if payday_lender_3mos2 !=1
label define payday_lender_3label 0 "no" 1 "yes"
label values payday_lender_3mos2 payday_lender_3label

replace bankloan_3mos2=0 if bankloan_3mos2 !=1
label define bankloan_3label 0 "no" 1 "yes"
label values bankloan_3mos2 bankloan_3label


**Binary variable indicating if a respondent received assistance paying their energy bill in the last 3 months
gen energy_assistance_3mos2=.

replace energy_assistance_3mos2=0 if gov_agency_3mos2==0 & energy_provider_3mos2==0 & friend_family_3mos2==0 & faith_org_3mos2==0 & nonprofit_3mos2==0 & payday_lender_3mos2==0 & bankloan_3mos2==0

replace energy_assistance_3mos2=1 if gov_agency_3mos2==1 | energy_provider_3mos2==1 | friend_family_3mos2==1 | faith_org_3mos2==1 | nonprofit_3mos2==1 | payday_lender_3mos2==1 | bankloan_3mos2==1

label define energy_assist3label 0 "No assistance" 1 "Assistance from at least one source"
label values energy_assistance_3mos2 energy_assist3label



**did a respondent receieve assistance in paying their energy bill in June from the following sources: government agency, their energy provider, a friend or family member, a faith-based organization, a nonprofit, a payday lender, or a bank loan
rename q31a_1 gov_agency_june
rename q31b_1 energy_provider_june
rename q31c_1 friend_family_june
rename q31d_1 faith_org_june
rename q31e_1 nonprofit_june
rename q31f_1 payday_lender_june
rename q31g_1 bankloan_june


replace gov_agency_june=0 if gov_agency_june !=1
label define gov_agency_junelabel 0 "no" 1 "yes"
label values gov_agency_june gov_agency_junelabel

replace energy_provider_june=0 if energy_provider_june !=1
label define energy_provider_junelabel 0 "no" 1 "yes"
label values energy_provider_june energy_provider_junelabel

replace friend_family_june=0 if friend_family_june !=1
label define friend_family_junelabel 0 "no" 1 "yes"
label values friend_family_june friend_family_junelabel

replace faith_org_june=0 if faith_org_june !=1
label define faith_org_junelabel 0 "no" 1 "yes"
label values faith_org_june faith_org_junelabel

replace nonprofit_june=0 if nonprofit_june !=1
label define nonprofit_junelabel 0 "no" 1 "yes"
label values nonprofit_june nonprofit_junelabel

replace payday_lender_june=0 if payday_lender_june !=1
label define payday_lender_junelabel 0 "no" 1 "yes"
label values payday_lender_june payday_lender_junelabel

replace bankloan_june=0 if bankloan_june !=1
label define bankloan_junelabel 0 "no" 1 "yes"
label values bankloan_june bankloan_junelabel


**Binary variable indicating if a respondent received assistance paying their energy bill in June
gen energy_assistance_june=.

replace energy_assistance_june=0 if gov_agency_june==0 & energy_provider_june==0 & friend_family_june==0 & faith_org_june==0 & nonprofit_june==0 & payday_lender_june==0 & bankloan_june==0

replace energy_assistance_june=1 if gov_agency_june==1 | energy_provider_june==1 | friend_family_june==1 | faith_org_june==1 | nonprofit_june==1 | payday_lender_june==1 | bankloan_june==1

label define energy_assistjunelabel 0 "No assistance" 1 "Assistance from at least one source"
label values energy_assistance_june energy_assistjunelabel



**did a respondent receieve assistance in paying their energy bill in July from the following sources: government agency, their energy provider, a friend or family member, a faith-based organization, a nonprofit, a payday lender, or a bank loan
rename q31a_2 gov_agency_july
rename q31b_2 energy_provider_july
rename q31c_2 friend_family_july
rename q31d_2 faith_org_july
rename q31e_2 nonprofit_july
rename q31f_2 payday_lender_july
rename q31g_2 bankloan_july

replace gov_agency_july=0 if gov_agency_july !=1
label define gov_agency_julylabel 0 "no" 1 "yes"
label values gov_agency_july gov_agency_julylabel

replace energy_provider_july=0 if energy_provider_july !=1
label define energy_provider_julylabel 0 "no" 1 "yes"
label values energy_provider_july energy_provider_julylabel

replace friend_family_july=0 if friend_family_july !=1
label define friend_family_julylabel 0 "no" 1 "yes"
label values friend_family_july friend_family_julylabel

replace faith_org_july=0 if faith_org_july !=1
label define faith_org_julylabel 0 "no" 1 "yes"
label values faith_org_july faith_org_julylabel

replace nonprofit_july=0 if nonprofit_july !=1
label define nonprofit_julylabel 0 "no" 1 "yes"
label values nonprofit_july nonprofit_julylabel

replace payday_lender_july=0 if payday_lender_july !=1
label define payday_lender_julylabel 0 "no" 1 "yes"
label values payday_lender_july payday_lender_julylabel

replace bankloan_july=0 if bankloan_july !=1
label define bankloan_julylabel 0 "no" 1 "yes"
label values bankloan_july bankloan_julylabel


**Binary variable indicating if a respondent received assistance paying their energy bill in July
gen energy_assistance_july=.

replace energy_assistance_july=0 if gov_agency_july==0 & energy_provider_july==0 & friend_family_july==0 & faith_org_july==0 & nonprofit_july==0 & payday_lender_july==0 & bankloan_july==0

replace energy_assistance_july=1 if gov_agency_july==1 | energy_provider_july==1 | friend_family_july==1 | faith_org_july==1 | nonprofit_july==1 | payday_lender_july==1 | bankloan_july==1

label define energy_assistjulylabel 0 "No assistance" 1 "Assistance from at least one source"
label values energy_assistance_july energy_assistjulylabel



**did a respondent receieve assistance in paying their energy bill in august from the following sources: government agency, their energy provider, a friend or family member, a faith-based organization, a nonprofit, a payday lender, or a bank loan
rename q31a_3 gov_agency_august
rename q31b_3 energy_provider_august
rename q31c_3 friend_family_august
rename q31d_3 faith_org_august
rename q31e_3 nonprofit_august
rename q31f_3 payday_lender_august
rename q31g_3 bankloan_august

replace gov_agency_august=0 if gov_agency_august !=1
label define gov_agency_augustlabel 0 "no" 1 "yes"
label values gov_agency_august gov_agency_augustlabel

replace energy_provider_august=0 if energy_provider_august !=1
label define energy_provider_augustlabel 0 "no" 1 "yes"
label values energy_provider_august energy_provider_augustlabel

replace friend_family_august=0 if friend_family_august !=1
label define friend_family_augustlabel 0 "no" 1 "yes"
label values friend_family_august friend_family_augustlabel

replace faith_org_august=0 if faith_org_august !=1
label define faith_org_augustlabel 0 "no" 1 "yes"
label values faith_org_august faith_org_augustlabel

replace nonprofit_august=0 if nonprofit_august !=1
label define nonprofit_augustlabel 0 "no" 1 "yes"
label values nonprofit_august nonprofit_augustlabel

replace payday_lender_august=0 if payday_lender_august !=1
label define payday_lender_augustlabel 0 "no" 1 "yes"
label values payday_lender_august payday_lender_augustlabel

replace bankloan_august=0 if bankloan_august !=1
label define bankloan_augustlabel 0 "no" 1 "yes"
label values bankloan_august bankloan_augustlabel


**Binary variable indicating if a respondent received assistance paying their energy bill in august
gen energy_assistance_august=.

replace energy_assistance_august=0 if gov_agency_august==0 & energy_provider_august==0 & friend_family_august==0 & faith_org_august==0 & nonprofit_august==0 & payday_lender_august==0 & bankloan_august==0

replace energy_assistance_august=1 if gov_agency_august==1 | energy_provider_august==1 | friend_family_august==1 | faith_org_august==1 | nonprofit_august==1 | payday_lender_august==1 | bankloan_august==1

label define energy_assistaugustlabel 0 "No assistance" 1 "Assistance from at least one source"
label values energy_assistance_august energy_assistaugustlabel



**did respondent have to forgo basic household expenses to pay an energy bill in the last 3 months
gen forego_expenses_3mos2=0
replace forego_expenses_3mo=1 if q31_forgo==1

gen forego_expenses_june=0
replace forego_expenses_june=1 if q32_1==1

gen forego_expenses_july=0
replace forego_expenses_july=1 if q32_2==1

gen forego_expenses_august=0
replace forego_expenses_august=1 if q32_3==1


**did respondent receive WAP (Weatherization Assistance Program), LIHEAP (Low-Income Housing Energy Assistance Progam), SNAP, TANF, SSI, Medicaid, Veterans Benefits, Unemployment Insurance, and a COVID stimulus check in the last 3 months
rename q33_1 wap_3mos2
rename q33_2 liheap_3mos2
rename q33_3 snap_3mos2
rename q33_4 tanf_3mos2
rename q33_5 ssi_3mos2
rename q33_6 medicaid_3mos2
rename q33_7 medicare_3mos2
rename q33_8 vet_benefits_3mos2
rename q33_9 unemp_insurance_3mos2
rename q33_10 covid_stimulus2

replace wap_3mos2=0 if wap_3mos2 !=1
label define wap_3label 0 "no" 1 "yes"
label values wap_3mos2 wap_3label

replace liheap_3mos2=0 if liheap_3mos2 !=1
label define liheap_3label 0 "no" 1 "yes"
label values liheap_3mos2 liheap_3label

replace snap_3mos2=0 if snap_3mos2 !=1
label define snap_3label 0 "no" 1 "yes"
label values snap_3mos2 snap_3label

replace tanf_3mos2=0 if tanf_3mos2 !=1
label define tanf_3label 0 "no" 1 "yes"
label values tanf_3mos2 tanf_3label

replace ssi_3mos2=0 if ssi_3mos2 !=1
label define ssi_3label 0 "no" 1 "yes"
label values ssi_3mos2 ssi_3label

replace medicaid_3mos2=0 if medicaid_3mos2 !=1
label define medicaid_3label 0 "no" 1 "yes"
label values medicaid_3mos2 medicaid_3label

replace vet_benefits_3mos2=0 if vet_benefits_3mos2 !=1
label define vet_benefits_3label 0 "no" 1 "yes"
label values vet_benefits_3mos2 vet_benefits_3label

replace unemp_insurance_3mos2=0 if unemp_insurance_3mos2 !=1
label define unemp_insurance_3label 0 "no" 1 "yes"
label values unemp_insurance_3mos2 unemp_insurance_3label

recode covid_stimulus2 (2=0)
label var covid_stimulus2 "Received Stimulus?"
label define stimulus_label 0 "No" 1 "Yes"
label values covid_stimulus2 stimulus_label


**Binary variable representing whether respondent received government assistance in the previous 3 months
gen gov_assistance_3months2=.

replace gov_assistance_3months2=0 if wap_3mos2==0 & liheap_3mos2==0 & snap_3mos2==0 & tanf_3mos2==0 & ssi_3mos2==0 & medicaid_3mos2==0 & vet_benefits_3mos2==0 & unemp_insurance_3mos2==0

replace gov_assistance_3months2=1 if wap_3mos2==1 | liheap_3mos2==1 | snap_3mos2==1 | tanf_3mos2==1 | ssi_3mos2==1 | medicaid_3mos2==1 | vet_benefits_3mos2==1 | unemp_insurance_3mos2==1

label define gov_assist3months2label 0 "No assistance" 1 "Assistance from at least one source"
label values gov_assistance_3months2 gov_assist3months2label


**did respondent receive WAP (Weatherization Assistance Program), LIHEAP (Low-Income Housing Energy Assistance Progam), SNAP, TANF, SSI, Medicaid, Veterans Benefits, Unemployment Insurance, and a COVID stimulus check in June
rename q36a_1 wap_june
rename q36b_1 liheap_june
rename q36c_1 snap_june
rename q36d_1 tanf_june
rename q36e_1 ssi_june
rename q36f_1 medicaid_june
rename q36g_1 medicare_june
rename q36h_1 vet_benefits_june
rename q36i_1 unemp_insurance_june
rename q36j_1 stimulus_june

replace wap_june=0 if wap_june !=1
label define wap_junelabel 0 "no" 1 "yes"
label values wap_june wap_junelabel

replace liheap_june=0 if liheap_june !=1
label define liheap_junelabel 0 "no" 1 "yes"
label values liheap_june liheap_junelabel

replace snap_june=0 if snap_june !=1
label define snap_junelabel 0 "no" 1 "yes"
label values snap_june snap_junelabel

replace tanf_june=0 if tanf_june !=1
label define tanf_junelabel 0 "no" 1 "yes"
label values tanf_june tanf_junelabel

replace ssi_june=0 if ssi_june !=1
label define ssi_junelabel 0 "no" 1 "yes"
label values ssi_june ssi_junelabel

replace medicaid_june=0 if medicaid_june !=1
label define medicaid_junelabel 0 "no" 1 "yes"
label values medicaid_june medicaid_junelabel

replace vet_benefits_june=0 if vet_benefits_june !=1
label define vet_benefits_junelabel 0 "no" 1 "yes"
label values vet_benefits_june vet_benefits_junelabel

replace unemp_insurance_june=0 if unemp_insurance_june !=1
label define unemp_insurance_junelabel 0 "no" 1 "yes"
label values unemp_insurance_june unemp_insurance_junelabel



**Binary variable representing whether respondent received government assistance in June
gen gov_assistance_june=.

replace gov_assistance_june=0 if wap_june==0 & liheap_june==0 & snap_june==0 & tanf_june==0 & ssi_june==0 & medicaid_june==0 & vet_benefits_june==0 & unemp_insurance_june==0

replace gov_assistance_june=1 if wap_june==1 | liheap_june==1 | snap_june==1 | tanf_june==1 | ssi_june==1 | medicaid_june==1 | vet_benefits_june==1 | unemp_insurance_june==1

label define gov_assistjunelabel 0 "No assistance" 1 "Assistance from at least one source"
label values gov_assistance_june gov_assistjunelabel


**did respondent receive WAP (Weatherization Assistance Program), LIHEAP (Low-Income Housing Energy Assistance Progam), SNAP, TANF, SSI, Medicaid, Veterans Benefits, Unemployment Insurance, and a COVID stimulus check in July
rename q36a_2 wap_july
rename q36b_2 liheap_july
rename q36c_2 snap_july
rename q36d_2 tanf_july
rename q36e_2 ssi_july
rename q36f_2 medicaid_july
rename q36g_2 medicare_july
rename q36h_2 vet_benefits_july
rename q36i_2 unemp_insurance_july
rename q36j_2 stimulus_july


replace wap_july=0 if wap_july !=1
label define wap_julylabel 0 "no" 1 "yes"
label values wap_july wap_julylabel

replace liheap_july=0 if liheap_july !=1
label define liheap_julylabel 0 "no" 1 "yes"
label values liheap_july liheap_julylabel

replace snap_july=0 if snap_july !=1
label define snap_julylabel 0 "no" 1 "yes"
label values snap_july snap_julylabel

replace tanf_july=0 if tanf_july !=1
label define tanf_julylabel 0 "no" 1 "yes"
label values tanf_july tanf_julylabel

replace ssi_july=0 if ssi_july !=1
label define ssi_julylabel 0 "no" 1 "yes"
label values ssi_july ssi_julylabel

replace medicaid_july=0 if medicaid_july !=1
label define medicaid_julylabel 0 "no" 1 "yes"
label values medicaid_july medicaid_julylabel

replace vet_benefits_july=0 if vet_benefits_july !=1
label define vet_benefits_julylabel 0 "no" 1 "yes"
label values vet_benefits_july vet_benefits_julylabel

replace unemp_insurance_july=0 if unemp_insurance_july !=1
label define unemp_insurance_julylabel 0 "no" 1 "yes"
label values unemp_insurance_july unemp_insurance_julylabel



**Binary variable representing whether respondent received government assistance in July
gen gov_assistance_july=.

replace gov_assistance_july=0 if wap_july==0 & liheap_july==0 & snap_july==0 & tanf_july==0 & ssi_july==0 & medicaid_july==0 & vet_benefits_july==0 & unemp_insurance_july==0

replace gov_assistance_july=1 if wap_july==1 | liheap_july==1 | snap_july==1 | tanf_july==1 | ssi_july==1 | medicaid_july==1 | vet_benefits_july==1 | unemp_insurance_july==1

label define gov_assistjulylabel 0 "No assistance" 1 "Assistance from at least one source"
label values gov_assistance_july gov_assistjulylabel


**did respondent receive WAP (Weatherization Assistance Program), LIHEAP (Low-Income Housing Energy Assistance Progam), SNAP, TANF, SSI, Medicaid, Veterans Benefits, Unemployment Insurance, and a COVID stimulus check in August
rename q36a_3 wap_august
rename q36b_3 liheap_august
rename q36c_3 snap_august
rename q36d_3 tanf_august
rename q36e_3 ssi_august
rename q36f_3 medicaid_august
rename q36g_3 medicare_august
rename q36h_3 vet_benefits_august
rename q36i_3 unemp_insurance_august
rename q36j_3 stimulus_august

replace wap_august=0 if wap_august !=1
label define wap_augustlabel 0 "no" 1 "yes"
label values wap_august wap_augustlabel

replace liheap_august=0 if liheap_august !=1
label define liheap_augustlabel 0 "no" 1 "yes"
label values liheap_august liheap_augustlabel

replace snap_august=0 if snap_august !=1
label define snap_augustlabel 0 "no" 1 "yes"
label values snap_august snap_augustlabel

replace tanf_august=0 if tanf_august !=1
label define tanf_augustlabel 0 "no" 1 "yes"
label values tanf_august tanf_augustlabel

replace ssi_august=0 if ssi_august !=1
label define ssi_augustlabel 0 "no" 1 "yes"
label values ssi_august ssi_augustlabel

replace medicaid_august=0 if medicaid_august !=1
label define medicaid_augustlabel 0 "no" 1 "yes"
label values medicaid_august medicaid_augustlabel

replace vet_benefits_august=0 if vet_benefits_august !=1
label define vet_benefits_augustlabel 0 "no" 1 "yes"
label values vet_benefits_august vet_benefits_augustlabel

replace unemp_insurance_august=0 if unemp_insurance_august !=1
label define unemp_insurance_augustlabel 0 "no" 1 "yes"
label values unemp_insurance_august unemp_insurance_augustlabel



**Binary variable representing whether respondent received government assistance in august
gen gov_assistance_august=.

replace gov_assistance_august=0 if wap_august==0 & liheap_august==0 & snap_august==0 & tanf_august==0 & ssi_august==0 & medicaid_august==0 & vet_benefits_august==0 & unemp_insurance_august==0

replace gov_assistance_august=1 if wap_august==1 | liheap_august==1 | snap_august==1 | tanf_august==1 | ssi_august==1 | medicaid_august==1 | vet_benefits_august==1 | unemp_insurance_august==1

label define gov_assistaugustlabel 0 "No assistance" 1 "Assistance from at least one source"
label values gov_assistance_august gov_assistaugustlabel



*Was respondent deemed ineligible for a government assistance program in which they applied
rename q34 assistance_ineligible2
recode assistance_ineligible2 (2=0)

rename q35_1 ineligible_wap2
rename q35_2 ineligible_liheap2
rename q35_3 ineligible_snap2
rename q35_4 ineligible_tanf2
rename q35_5 ineligible_ssi2
rename q35_6 ineligible_medicaid2
rename q35_7 ineligible_medicare2
rename q35_8 ineligible_vet_benefits2
rename q35_9 ineligible_unemp_insurance2

*why were they deemed inelligible?
rename q36 ineligible_reason2


**Respondent used the following methods to stay warm in their home in the last 3 months
rename q38_1 stove_3mos2
rename q38_2 spaceheater_3mos2
rename q38_3 woodstove_3mos2
rename q38_4 fireplace_3mos2
rename q38_5 hotshower_3mos2
rename q38_6 burntrash_3mos2
rename q38_7 heavycoat_3mos2
rename q38_8 dryer_3mos2

replace stove_3mos2=0 if stove_3mos2 !=1
label define stove_3label 0 "no" 1 "yes"
label values stove_3mos2 stove_3label

replace spaceheater_3mos2=0 if spaceheater_3mos2 !=1
label define spaceheater_3label 0 "no" 1 "yes"
label values spaceheater_3mos2 spaceheater_3label

replace woodstove_3mos2=0 if woodstove_3mos2 !=1
label define woodstove_3label 0 "no" 1 "yes"
label values woodstove_3mos2 woodstove_3label

replace fireplace_3mos2=0 if fireplace_3mos2 !=1
label define fireplace_3label 0 "no" 1 "yes"
label values fireplace_3mos2 fireplace_3label

replace hotshower_3mos2=0 if hotshower_3mos2 !=1
label define hotshower_3label 0 "no" 1 "yes"
label values hotshower_3mos2 hotshower_3label

replace burntrash_3mos2=0 if burntrash_3mos2 !=1
label define burntrash_3label 0 "no" 1 "yes"
label values burntrash_3mos2 burntrash_3label

replace heavycoat_3mos2=0 if heavycoat_3mos2 !=1
label define heavycoat_3label 0 "no" 1 "yes"
label values heavycoat_3mos2 heavycoat_3label

replace dryer_3mos2=0 if dryer_3mos2 !=1
label define dryer_3label 0 "no" 1 "yes"
label values dryer_3mos2 dryer_3label


**binary variable representing whether a respondent used at least one strategy to stay warm in the last 3 months
gen staywarm_3mos2=.

replace staywarm_3mos2=0 if stove_3mos2==0 & spaceheater_3mos2==0 & woodstove_3mos2==0 & fireplace_3mos2==0 & hotshower_3mos2==0 & burntrash_3mos2==0 & heavycoat_3mos2==0 & dryer_3mos2==0


replace staywarm_3mos2=1 if stove_3mos2==1 | spaceheater_3mos2==1 | woodstove_3mos2==1 | fireplace_3mos2==1 | hotshower_3mos2==1 | burntrash_3mos2==1 | heavycoat_3mos2==1 | dryer_3mos2==1


label define staywarm_3mos2label 0 "No coping strategies" 1 "At least one coping strategy"
label values staywarm_3mos2 staywarm_3mos2label






**Respondent used the following methods to stay cool in their home in the last 3 months
rename q39_1 centralac_3mos2
rename q39_2 windowac_3mos2
rename q39_3 fan_3mos2
rename q39_4 dehumidifier_3mos2
rename q39_5 lefthouse_3mos2
rename q39_6 openedwindows_3mos2
rename q39_7 boughtice_3mos2
rename q39_8 coldshowers_3mos2


replace centralac_3mos2=0 if centralac_3mos2 !=1
label define centralac_3label 0 "no" 1 "yes"
label values centralac_3mos2 centralac_3label

replace windowac_3mos2=0 if windowac_3mos2 !=1
label define windowac_3label 0 "no" 1 "yes"
label values windowac_3mos2 windowac_3label

replace fan_3mos2=0 if fan_3mos2 !=1
label define fan_3label 0 "no" 1 "yes"
label values fan_3mos2 fan_3label

replace dehumidifier_3mos2=0 if dehumidifier_3mos2 !=1
label define dehumidifier_3label 0 "no" 1 "yes"
label values dehumidifier_3mos2 dehumidifier_3label

replace lefthouse_3mos2=0 if lefthouse_3mos2 !=1
label define lefthouse_3label 0 "no" 1 "yes"
label values lefthouse_3mos2 lefthouse_3label

replace openedwindows_3mos2=0 if openedwindows_3mos2 !=1
label define openedwindows_3label 0 "no" 1 "yes"
label values openedwindows_3mos2 openedwindows_3label

replace boughtice_3mos2=0 if boughtice_3mos2 !=1
label define boughtice_3label 0 "no" 1 "yes"
label values boughtice_3mos2 boughtice_3label

replace coldshowers_3mos2=0 if coldshowers_3mos2 !=1
label define coldshowers_3label 0 "no" 1 "yes"
label values coldshowers_3mos2 coldshowers_3label


**binary variable representing whether a respondent used at least one strategy to stay cool in the last 3 months
gen staycool_3mos2=.

replace staycool_3mos2=0 if centralac_3mos2==0 & windowac_3mos2==0 & fan_3mos2==0 & dehumidifier_3mos2==0 & lefthouse_3mos2==0 & openedwindows_3mos2==0 & boughtice_3mos2==0 & coldshowers_3mos2==0


replace staycool_3mos2=1 if centralac_3mos2==1 | windowac_3mos2==1 | fan_3mos2==1 | dehumidifier_3mos2==1 | lefthouse_3mos2==1 | openedwindows_3mos2==1 | boughtice_3mos2==1 | coldshowers_3mos2==1


label define staycool_3mos2label 0 "No coping strategies" 1 "At least one coping strategy"
label values staycool_3mos2 staycool_3mos2label

**did respondent indicate that they used air conditioning to stay cool
gen no_ac2=0
replace no_ac2=1 if centralac_3mos2 ==0 & windowac_3mos2 ==0
label define no_ac_label 0 "Used AC" 1 "Did not use AC"
label values no_ac2 no_ac_label

**if respondent did not use air conditioning, why not (don't have A/C, chose not to use, did not need it, or unit is not functioning)
rename q40 no_ac_reason2
label define noac_label 1 "Do not have air conditioning" 2 "Choose not to use it" 3 "Unit is not functioning" 4 "Did not need it"
label values no_ac_reason2 noac_label

**respondent has a positive COVID diagnosis
gen covid_positive2=0
replace covid_positive2=1 if q41_1==1

**respondent reported having COVID symptoms
gen covid_symptoms2=0
replace covid_symptoms2=1 if q41_2==1

**respondent had their employment impacted by the COVID hsutdowns (reduced hours, furloughed, lost employment, re-entered the workforce, decided not to work, or no change in employment)
rename q42 covid_employment2
label define covid_employment2_label 1 "Reduced hours at job" 2 "Furloughed with pay" 3 "Furloughed without pay" 4 "Lost employment" 5 "Re-entered the workforce" 6 "Decided not to work" 7 "My employment status did not change" 8 "Other"
label values covid_employment2 covid_employment2_label

gen covid_lostjobhours2=0
replace covid_lostjobhours=1 if covid_employment==1 | covid_employment==3 | covid_employment==4
label define lostjob 1 "Loss job or reduced hours" 0 "Retained job"
label val covid_lostjobhours2 lostjob

**Date that respondent lost employment
rename q43 date_unemployed2

**Did respondents health insurance change during COVID
rename q44 covid_insurance2
label define covid_insurance2_label 1 "Yes, I lost my health insurance" 2 "No, but my employed put me on a less generous plan" 3 "No, my health insurance plan is the same" 4 "I didn't have health insurance before COVID-19"
label values covid_insurance2 covid_insurance2_label

rename q45 month_lostinsurance2

**Did respondent experience economic hardships due to the pandemic, including: struggling to pay rent, struggling to feed family, and struggling to receive medical care
rename q47 covid_rent2
label define covid_rent2_label 1 "Strongly disagree" 2 "Somewhat disagree" 3 "Neither agree nor disagree" 4 "Somewhat agree" 5 "Strongly agree"
label values covid_rent2 covid_rent2_label
rename q48 covid_feedfamily2
label define covid_feedfamily2_label 1 "Strongly disagree" 2 "Somewhat disagree" 3 "Neither agree nor disagree" 4 "Somewhat agree" 5 "Strongly agree"
label values covid_feedfamily2 covid_feedfamily2_label
rename q49 covid_medicalcare2
label define covid_medicalcare2_label 1 "Strongly disagree" 2 "Somewhat disagree" 3 "Neither agree nor disagree" 4 "Somewhat agree" 5 "Strongly agree"
label values covid_medicalcare2 covid_medicalcare2_label

**is respondent spending more time at home during the pandemic?
rename q50 covid_stayinghome2

**since states began reopening, how often do respondents go out in public
rename q51 covid_reopen2



**By which method does respondent pay their energy bill (check, credit, debit, bank withdrawal, or cash)?
rename q52_1 utilitypay_check2
recode utilitypay_check2 (2=0)
label define check_label 0 "no" 1 "yes"
label values utilitypay_check2 check_label
rename q52_2 utilitypay_credit2
recode utilitypay_credit2 (2=0)
label define credit_label 0 "no" 1 "yes"
label values utilitypay_credit2 credit_label
rename q52_3 utilitypay_debit2
recode utilitypay_debit2 (2=0)
label define debit_label 0 "no" 1 "yes"
label values utilitypay_debit2 debit_label
rename q52_4 utilitypay_withdrawal2
recode utilitypay_withdrawal2 (2=0)
label define withdrawal_label 0 "no" 1 "yes"
label values utilitypay_withdrawal2 withdrawal_label
rename q52_5 utilitypay_cash2
recode utilitypay_cash2 (2=0)
label define cash_label 0 "no" 1 "yes"
label values utilitypay_cash2 cash_label

**Does respondent typically pay their energy bill in full, in part, in intervals, or not at all?
rename q53 utilitybill_pay2
label define pay_label 1 "Pay it in full" 2 "Pay a portion of it" 3 "Pay it every other month or some other interval" 4 "Not pay it" 5 "Other"
label values utilitybill_pay2 pay_label

**What do respondents do when they cannot pay their utility bill (borrow from friends, take out a payday loan, use a credit card, or do not pay until they receive a disconnection notice)
rename q54_1 utilityhelp_friend2
recode utilityhelp_friend2 (2=0)
label define friend_label 0 "no" 1 "yes"
label values utilityhelp_friend2 friend_label
rename q54_2 utilityhelp_paydayloan2
recode utilityhelp_paydayloan2 (2=0)
label define paydayloan_label 0 "no" 1 "yes"
label values utilityhelp_paydayloan2 paydayloan_label
rename q54_3 utilityhelp_credit2
recode utilityhelp_credit2 (2=0)
label define utilitycredit_label 0 "no" 1 "yes"
label values utilityhelp_credit2 utilitycredit_label
rename q54_4 utilityhelp_notice2
recode utilityhelp_notice2 (2=0)
label define utilitynotice_label 0 "no" 1 "yes"
label values utilityhelp_notice2 utilitynotice_label


**Level of utility debt the household currently owes
rename q56 utility_debt2
recode utility_debt2 (1=0) (2=25) (3=50) (4=75) (5=100) (6=125) (7=150) (8=175) (9=200) (10=225) (11=250) (12=275) (13=300) (14=325) (15=350) (16=375) (17=400) (18=425) (19=450) (20=475) (21=500) (22=525) (23=550) (24=575) (25=600) (26=625) (27=650) (28=675) (29=700) (30=725) (31=750) (32=775) (33=800) (34=825) (35=850) (36=875) (37=900) (38=925) (39=950) (40=975) (41=1000) (42=1001)
label define utility_debt_label 0 "$0" 25 "$25" 50 "$50" 75 "$75" 100 "$100" 125 "$125" 150 "$150" 175 "$175" 200 "$200" 225 "$225" 250 "$250" 275 "$275" 300 "$300" 325 "$325" 350 "$350" 375 "$375" 400 "$400" 425 "$425" 450 "$450" 475 "$475" 500 "$500" 525 "$525" 550 "$550" 575 "$575" 600 "$600" 625 "$625" 650 "$650" 675 "$675" 700 "$700" 725 "$725" 750 "$750" 775 "$775" 800 "$800" 825 "$825" 850 "$850" 875 "$875" 900 "$900" 925 "$925" 950 "$950" 975 "$975" 1000 "$1000" 1001 "More than $1000"
label values utility_debt2 utility_debt_label


**Respondent has more than $1000 in utility debt
rename q57 debt_over10002
recode debt_over10002 (2=1)
label define over1000_label 1 "yes"
label values debt_over10002 over1000_label

**Are respondents behind on other payments (rent, credit cards, car payments, medical costs,bank loans, personal loans, or student loans?)
rename q58_1 behind_rent2
recode behind_rent2 (2=0)
label define behind_rentlabel 0 "no" 1 "yes"
label values behind_rent2 behind_rentlabel
rename q58_2 behind_credit2
recode behind_credit2 (2=0)
label define behind_creditlabel 0 "no" 1 "yes"
label values behind_credit2 behind_creditlabel
rename q58_3 behind_car2
recode behind_car2 (2=0)
label define behind_carlabel 0 "no" 1 "yes"
label values behind_car2 behind_carlabel
rename q58_4 behind_medical2
recode behind_medical2 (2=0)
label define behind_medicallabel 0 "no" 1 "yes"
label values behind_medical2 behind_medicallabel
rename q58_5 behind_bankloan2
recode behind_bankloan2 (2=0)
label define behind_bankloanlabel 0 "no" 1 "yes"
label values behind_bankloan2 behind_bankloanlabel
rename q58_6 behind_personalloan2
recode behind_personalloan2 (2=0)
label define behind_personalloanlabel 0 "no" 1 "yes"
label values behind_personalloan2 behind_personalloanlabel
rename q58_7 behind_studentloan2
recode behind_studentloan2 (2=0)
label define behind_studentloanlabel 0 "no" 1 "yes"
label values behind_studentloan2 behind_studentloanlabel

**Has respondent received a eviction notice in the last 3 months (June, July, or August?)
rename q59_1 evictnotice_june
recode evictnotice_june (2=0)
label define evictnotice_junelabel 0 "no" 1 "yes"
label values evictnotice_june evicted_junelabel
rename q59_2 evictnotice_july
recode evictnotice_july (2=0)
label define evictnotice_julylabel 0 "no" 1 "yes"
label values evictnotice_july evictnotice_julylabel
rename q59_3 evictnotice_august
recode evictnotice_august (2=0)
label define evictnotice_augustlabel 0 "no" 1 "yes"
label values evictnotice_august evictnotice_augustlabel

gen evictnotice_3months2=0
replace evictnotice_3months2=1 if evictnotice_june==1
replace evictnotice_3months2=2 if evictnotice_july==1
replace evictnotice_3months2=3 if evictnotice_august==1
label define evictnotice_3months2_label 0 "no" 1 "june" 2 "july" 3 "august"
label values evictnotice_3months2 evicted_3months2_label

**Has respondent been evicted in the last 3 months (June, July, or August)
rename q60 evictmonth_3months2
recode evictmonth_3months2 (4=0)

gen evicted_3months2=0
replace evicted_3months2 =1 if evictmonth_3months2 > 0
label define evicted_label 0 "no" 1 "yes"
label values evicted_3months2 evicted_label

gen evicted_june=0
replace evicted_june=1 if evictmonth_3months2==1
label define evicted_junelabel 0 "no" 1 "yes"
label values evicted_june evicted_junelabel

gen evicted_july=0
replace evicted_july=1 if evictmonth_3months2==2
label define evicted_julylabel 0 "no" 1 "yes"
label values evicted_july evicted_julylabel

gen evicted_august=0
replace evicted_august=1 if evictmonth_3months2==3
label define evicted_augustlabel 0 "no" 1 "yes"
label values evicted_august evicted_augustlabel


**has respondent sought legal help to deal with utility disconnection
rename q61 legal_help2
recode legal_help2 (2=0)
label define legalhelp_label 0 "no" 1 "yes"
label values legal_help2 legalhelp_label
rename q62 legal_access2
recode legal_access2 (2=0)
label define legalaccess_label 0 "no" 1 "yes"
label values legal_access2 legalaccess_label
rename q63 legal_source2
label define legalsource_label 1 "Hired a lawyer" 2 "Got help from a friend, family member, or other personal contact" 3 "An organization provided free legal service" 4 "Other"
label values legal_source2 legalsource_label


**how does respondent generally rate their health
rename q64 generalhealth_rate2
label define healthrate_label 1 "Excellent" 2 "Very good" 3 "Good" 4 "Fair" 5 "Poor" 6 "Don't know/notsure"
label values generalhealth_rate2 healthrate_label

**does a household member have a medical condition that requires prescription medication
rename q65 prescription2
recode prescription2 (2=0)
label define prescription_label 0 "no" 1 "yes"
label values prescription2 prescription_label

**if a household member requires prescription meidcation, have they not been able to fill that prescription in the last 3 months?
rename q66 fill_prescription2
recode fill_prescription2 (2=0)
label define fillprescript_label 0 "no" 1 "yes"
label values fill_prescription2 fillprescript_label

**In how many days over the last month did the respondent indicate that their mental health has been poor
rename q67 mentalhealth_days2
label define mentalhealth_label 0 "0" 1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6" 7 "7" 8 "8" 9 "9" 10 "10" 11 "11" 12 "12" 13 "13" 14 "14" 15 "15" 16 "16" 17 "17" 18 "18" 19 "19" 20 "20" 21 "21" 22 "22" 23 "23" 24 "24" 25 "25" 26 "26" 27 "27" 28 "28" 29 "29" 30 "30" 31 "Don't know/not sure"
label values mentalhealth_days2 mentalhealth_label


**Does respondent have various health consitions
gen highbloodpressure2=0
replace highbloodpressure2=1 if q68a==1
label define highpressure_label 0 "no" 1 "yes"
label values highbloodpressure2 highpressure_label
gen heartdisease2=0
replace heartdisease2=1 if q68b==1
label define heartdisease_label 0 "no" 1 "yes"
label values heartdisease2 heartdisease_label
gen diabetes2=0
replace diabetes2=1 if q68c==1
label define diabetes_label 0 "no" 1 "yes"
label values diabetes2 diabetes_label
gen cancer2=0
replace cancer2=1 if q68d==1
label define cancer_label 0 "no" 1 "yes"
label values cancer2 cancer_label
gen obesity2=0
replace obesity2=1 if q68e==1
label define obesity_label 0 "no" 1 "yes"
label values obesity2 obesity_label
gen asthma2=0
replace asthma2=1 if q68f==1
label define asthma_label 0 "no" 1 "yes"
label values asthma2 asthma_label



***************************Cleaning up variables*******************************
*lost insurance due to COVID*
gen covid_lostinsurance2=.
replace covid_lostinsurance2=0 if covid_insurance2 ==2 | covid_insurance2 ==3 | covid_insurance2 ==4
replace covid_lostinsurance2=1 if covid_insurance2==1
label define lostinsurance 0 "Did not lose insurance" 1 "Lost Insurance"
lab val covid_lostinsurance2 lostinsurance

**high school degree or less
gen educ_HS2 = (educ2==1|educ2==2)
label var educ_HS2 "respondent has high school degree or less"
label define educ_HS_label 0 "No" 1 "Yes"
label values educ_HS2 educ_HS_label

**any children under 5
gen any_under52 = (hh_under52>0)
recode any_under52 *=. if hh_under52==.
label var any_under52 "at least one person in the house is under 5"
label define any_label 0 "No" 1 "Yes"
label values any_under52 any_label

**any household members over 65
gen any_over652 = (hh_over652>0)
recode any_over652 *=. if hh_over652==.
label var any_over652 "at least one person in the house is over 65"
label define any_over_label 0 "No" 1 "Yes"
label values any_over652 any_over_label

**Lost work due to COVID
gen covid_lostwork2 = (covid_employment2==1|covid_employment2==3|covid_employment2==4)
recode covid_lostwork2 *=. if covid_employment2==.
label var covid_lostwork2 "Respondent lost work pay or hours due to the pandemic"
label define lostwork_label 0 "No" 1 "Yes"
label values covid_lostwork2 lostwork_label

**no or worse insurance due to COVID
gen covid_lessinsurance2 = (covid_insurance2==1| covid_insurance2==2)
recode covid_lessinsurance2 *=. if covid_insurance2==.
label var covid_lessinsurance2 "respondent lost health insurance or employer put them on less generous plan"
label define less_insure_label 0 "No" 1 "Yes"
label values covid_lessinsurance2 less_insure_label

gen no_insurance2 = (covid_insurance2==1|covid_insurance2==4)
recode no_insurance2 *=. if covid_insurance2==.
label var no_insurance2 "respondent lost insurance or didn't have any to begin with"
label define no_insure_label 0 "No" 1 "Yes"
label values no_insurance2 no_insure_label


**any household memebrs with a disability
gen any_disability2 = (hh_disability2>0)
recode any_disability2 *=. if hh_disability2==.
label var any_disability2 "at least one person in the house has a disability"
label define any_disability_label 0 "No" 1 "Yes"
label values any_disability2 any_disability_label

**respondent lives in a trailer or mobile home
gen home_trailer2 = (dwelling_type2==1)
recode home_trailer2 *=. if dwelling_type2==.
label var home_trailer2 "respondent's home is trailer or mobile home"
label define home_trailer_label 0 "No" 1 "Yes"
label values home_trailer2 home_trailer_label

**respondent lives in an apartment, duplex, or condo
gen home_apartmentcondo2 = (dwelling_type2==2)
recode home_apartmentcondo2 *=. if dwelling_type2==.
label var home_apartmentcondo2 "respondent's home is apartment, duplex, or condo"
label define home_apartmentcondo_label 0 "No" 1 "Yes"
label values home_apartmentcondo2 home_apartmentcondo_label

**respondent lives in a single family home
gen home_singlefam2 = (dwelling_type2==3|dwelling_type2==4)
recode home_singlefam2 *=. if dwelling_type2==.
label var home_singlefam2 "respondent's home is a single family home, either attached or detached"
label define home_singlefam_label 0 "No" 1 "Yes"
label values home_singlefam2 home_singlefam_label


**respondent indicated "other" as their dwelling type
gen home_other2 = (dwelling_type2==5)
recode home_other2 *=. if dwelling_type2==.
label var home_other2 "respondent's home is recorded as other"
label define home_other_label 0 "No" 1 "Yes"
label values home_other2 home_other_label

***respondent makes irregular utility payments
gen utilitybill_pay_irregular2 = (utilitybill_pay2==2|utilitybill_pay2==3|utilitybill_pay2==4)
recode utilitybill_pay_irregular2 *=. if utilitybill_pay2==.
label var utilitybill_pay_irregular2 "respondent pays portion of bill, every other bill, or doesn't pay"
label define irregular_label 0 "No" 1 "Yes"
label values utilitybill_pay_irregular2 irregular_label

**respondent has over $100 in utility debt
gen utilitydebt_over1002 = (utility_debt2>100)
recode utilitydebt_over1002 *=. if utility_debt2==.
label var utilitydebt_over1002 "respondent owes more than $100 in debt to utility"
label define over100_label 0 "No" 1 "Yes"
label values utilitydebt_over1002 over100_label

**respondent indicated their general health status was good to great
gen genhealth_goodtogreat2 = (generalhealth_rate2==1|generalhealth_rate2==2|generalhealth_rate2==3)
recode genhealth_goodtogreat2 *=. if generalhealth_rate2==.
label var genhealth_goodtogreat2 "respondent reports good, very good, or excellent overall health"
label define goodgreat_label 0 "No" 1 "Yes"
label values genhealth_goodtogreat2 goodgreat_label

**rename open responses
rename employ_t employmentstatus_open2
rename q68_other chronic_conditions_open2
rename q57_open debt_over1000_open2
rename q55_open maintainbills_open2
rename q53_open utilitybillpay_open2
rename q54_open utilitybillhelp_open2
rename q52_open utilitypaymethod_open2
rename q42_open covid_employmentchange_open2
rename q39_open staycool_open2
rename q38_open staywarm_open2
rename q33_open govassist_open2
rename q30_open energyassist_open2
rename q22_open response_notice_open2
rename q14_open energyefficiency_open2










****FPL levels (numeric)****
gen hhinc2 = "100% FPL or below" if hh1_income2==1
forvalues i = 2(1)8 {
replace hhinc2 = "100% FPL or below" if hh`i'_income2==1
}
forvalues i = 1(1)8 {
replace hhinc2 = "100%-150% FPL" if hh`i'_income2==2 | hh`i'_income2==3
}
forvalues i = 1(1)8 {
replace hhinc2 = "150%-200% FPL" if hh`i'_income2==4 | hh`i'_income2==5
}
forvalues i = 1(1)8 {
replace hhinc2 = "Over 200% FPL" if hh`i'_income2==6
}
encode hhinc2, gen(fpl2)


***Income levels by FPL***
gen under_100_fpl2=.
replace under_100_fpl2=0 if fpl2==2 | fpl2==3 | fpl2==4
replace under_100_fpl2=1 if fpl2==1

gen FPL_100_1502=.
replace FPL_100_1502=0 if fpl2==1 | fpl2==3 | fpl2==4
replace FPL_100_1502=1 if fpl2==2

gen FPL_150_2002=.
replace FPL_150_2002=0 if fpl2==1 | fpl2==2 | fpl2==4
replace FPL_150_2002=1 if fpl2==3

gen FPL_over_2002=.
replace FPL_over_2002=0 if fpl2==1 | fpl2==2 | fpl2==3
replace FPL_over_2002=1 if fpl2==4



rename ownhome ownhome2

gen homeowner2 = 0
replace homeowner2 = 0 if ownhome2 ==2 | ownhome2 ==3
replace homeowner2 = 1 if ownhome2 ==1
label var homeowner2 "own home?"
label define homeownerlabel 0 "no" 1 "yes"
label values homeowner2 homeownerlabel

gen employed2 = 0
replace employed2 = 0 if employ >1
replace employed2 = 1 if employ <3
label var employed2 "employed?"
label define employedlabel 0 "no" 1 "yes"
label values employed2 employedlabel

gen unemployed2 =0
replace unemployed2 =1 if employ==3 | employ==4
label var unemployed2 "unemployed"
label define unemployed2label 0 "no" 1 "yes"
label values unemployed2 unemployed2label

gen retired = 0
replace retired = 1 if employ ==5
replace retired = 0 if (employ <5|employ >5)
label var retired "retired?"
label define retiredlabel 0 "no" 1 "yes"
label values retired retiredlabel

rename employ employ2


gen white=0
replace white=1 if race==1

gen black=0
replace black=1 if race==2

gen hispanic=0
replace hispanic=1 if race==3

gen native_american=0
replace native_american=1 if race==5

gen female=0
replace female=1 if gender==2


gen wave2=1

*****Merge zip code, urban vs rural percentage*****
sort inputzip
merge m:1 inputzip using zcta_urban_v2.dta
drop if _m==2
rename inputzip inputzip2

save energy_insecurity_survey_wave2v2.dta, replace


** Code utility for each respondent

** Organize utility ownership data
clear
import excel "Operational_Data_2018.xlsx", sheet("States") cellrange(A3:AF2310) firstrow
keep UtilityName OwnershipType
rename UtilityName utility
sort utility
save utility_ownership, replace

** Identify respondent utility from survey response
clear
use energy_insecurity_survey_wave2v2.dta
keep caseid electric_insert* q9

reshape long electric_insert_, i(caseid q9) j(flag)
gen match=1 if q9==flag
gen utility = electric_insert_ if match==1
drop flag electric_insert_ q9 
sort caseid
collapse (max) match, by(caseid utility)
sort caseid utility
drop if caseid==caseid[_n+1]
drop match

** Merge with utility ownership data
sort utility
merge m:m utility using utility_ownership
drop if _m==2

** Code missing
replace Own="Municipal" if Own=="" & _m==1 & utility!=""
replace Own="Cooperative" if _m==1 & utility=="Western Illinois Elec Coop"
replace Own="Cooperative" if _m==1 & utility=="West Oregon Electric Coop Inc"
replace Own="Investor Owned" if _m==1 & utility=="Liberty Utilities (Granite State Electric)"
replace Own="Investor Owned" if _m==1 & utility=="DC    Potomac Electric Power Co"

drop _m
sort caseid
save caseid_utility, replace
clear

** Merge into survey file
use energy_insecurity_survey_wave2v2.dta
drop _m
sort caseid
merge 1:1 caseid using caseid_utility
drop _m

erase caseid_utility.dta
erase utility_ownership.dta

save energy_insecurity_survey_wave2v3.dta, replace
